<?php
namespace Menu\Model;
use Think\Model;
class AlbumModel extends Model {
	public function AlbumAdd($album_cover){
		$data = $this->create();
		$data['album_cover'] = $album_cover;
		$data['addtime']     = time();
		if($this->add($data)){
			$msg['info'] = "添加相册成功";
			$msg['number'] = 1;
		}
		return $msg;
	}

	public function Read(){
		$count      = $this->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,10);// 实例化分页类 传入总记录数和每页显示的记录数(25)
		$show       = $Page->show();// 分页显示输出
		// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
		$list = $this->limit($Page->firstRow.','.$Page->listRows)->select();
		$data['list'] = $list;
		$data['page'] = $show;
		return $data;
	}

	public function oneList($album_id){
		$where = array('album_id'=>$album_id);
		$data = $this
		->where($where)
		->find();
		return $data;
	}

	public function albumUpdate($album_id,$photo_cover){
		$where = array('album_id'=>$album_id);
		$data = $this->create();
		$data['album_cover'] = $photo_cover;
		$Resoult = $this
		->where($where)
		->save($data);
		if($Resoult){
			$msg['info'] = "修改成功";
			$msg['number'] = 1;
		}
		return $msg ;
	}

	public function del($album_id){
		if($this->delete($album_id)){
			$msg = 1;
		}else{
			$msg = 0;
		}
		return $msg;
	}
}